<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="130px">
      <el-form-item label="报告文号" prop="reportNo">
        <el-input
          v-model.trim="queryParams.reportNo"
          placeholder="请输入报告文号"
          clearable
          size="small"
          class="width170"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="客户名称（被审验单位名称）" prop="customerName">
        <el-input
          v-model.trim="queryParams.customerName"
          placeholder="请输入客户名称（被审验单位名称）"
          clearable
          size="small"
          class="width170"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="报备类型" prop="reportType">
        <el-select
          v-model="queryParams.reportType"
          placeholder="点击进行选择"
          clearable
          filterable
          size="small"
          class="width170"
          @change="handleQuery"
        >
          <el-option v-for="item in reportTypeOption" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue"/>
        </el-select>
      </el-form-item>
      <el-form-item label="审计年度">
       <!-- <el-date-picker
          v-model="queryParams.auditYearStartTime"
          size="small"
          class="width74"
          format="yyyy"
          value-format="yyyy"
          type="year"
          placeholder="开始"
          clearable
          :picker-options="pickerStartAuditYear"
          @change="handleQuery"
        ></el-date-picker>
        至
        <el-date-picker
          v-model="queryParams.auditYearEndTime"
          size="small"
          class="width74"
          format="yyyy"
          value-format="yyyy"
          type="year"
          placeholder="结束"
          clearable
          :picker-options="pickerEndAuditYear"
          @change="handleQuery"
        ></el-date-picker>-->
        <el-input
          v-model.trim="queryParams.auditYear"
          placeholder="请输入审计年度"
          clearable
          size="small"
          class="width170"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="报告日期" prop="reportTime">
        <el-date-picker
          v-model="reportTime"
          size="small"
          class="width170"
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          clearable
          @change="handleQuery"
        ></el-date-picker>
      </el-form-item>

      <el-form-item label="签字注师" prop="signerName1">
        <el-input
          v-model.trim="queryParams.signerName1"
          placeholder="请输入签字注师"
          clearable
          size="small"
          class="width170"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="签字注师编号" prop="signCertificateNo1">
        <el-input
          v-model.trim="queryParams.signCertificateNo1"
          placeholder="请输入签字注师编号"
          clearable
          size="small"
          class="width170"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="意见类型" prop="opinionType">
        <el-select
          v-model="queryParams.opinionType"
          placeholder="点击进行选择"
          clearable
          filterable
          size="small"
          class="width170"
          @blur="selectBlur"
          @clear="selectClear"
          @change="selectChange"
        >
          <el-option v-for="item in opinions" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue"/>
        </el-select>
      </el-form-item>
      <template v-if="toggleSearchStatus">
        <el-form-item label="客户营业执照号" prop="customerBusinessLicense">
          <el-input
            v-model.trim="queryParams.customerBusinessLicense"
            placeholder="请输入客户营业执照号"
            clearable
            size="small"
            class="width170"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="财政系统报备编码" prop="reportCode">
          <el-input
            v-model.trim="queryParams.reportCode"
            placeholder="请输入报备编码"
            clearable
            size="small"
            class="width170"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="财政系统报备状态" prop="reportStatus" v-judgeAccount="0">
          <el-input
            v-model="queryParams.reportStatus"
            placeholder="请输入报备状态"
            clearable
            size="small"
            class="width170"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="报备日期" prop="filingTime">
          <el-date-picker
            v-model="filingTime"
            size="small"
            class="width200"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            clearable
            @change="handleQuery"
          ></el-date-picker>

        <el-form-item label="报备年度">
          <el-date-picker
            v-model="queryParams.filingYearStartTime"
            size="small"
            class="width74"
            format="yyyy"
            value-format="yyyy"
            type="year"
            placeholder="开始"
            clearable
            :picker-options="pickerStartFilingYear"
            @change="handleQuery"
          ></el-date-picker>
          至
          <el-date-picker
            v-model="queryParams.filingYearEndTime"
            size="small"
            class="width74"
            format="yyyy"
            value-format="yyyy"
            type="year"
            placeholder="结束"
            clearable
            :picker-options="pickerEndFilingYear"
            @change="handleQuery"
          ></el-date-picker>
        </el-form-item>
        </el-form-item>
        <el-form-item label="财政退回审批时间" prop="applyVoidTime">
          <el-date-picker
            v-model="applyVoidTime"
            size="small"
            class="width300"
            format="yyyy-MM-dd HH:mm:ss"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            clearable
            @change="handleQuery"
          ></el-date-picker>
        </el-form-item>
        <el-form-item label="事务所所在地" prop="administrativeDivision" v-judgeAccount="0">
          <el-input
            v-model.trim="queryParams.administrativeDivision"
            placeholder="请输入事务所所在地"
            clearable
            size="small"
            class="width170"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="事务所名称" prop="firmName" v-judgeAccount="0">
          <el-input
            v-model.trim="queryParams.firmName"
            placeholder="请输入事务所名称"
            clearable
            size="small"
            class="width170"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="证券资格" prop="hasSecurities" v-judgeAccount="0">
          <el-select
            v-model="queryParams.hasSecurities"
            placeholder="点击进行选择"
            clearable
            size="small"
            class="width170"
            @change="handleQuery"
          >
            <el-option label="是" value="是"/>
            <el-option label="否" value="否"/>
          </el-select>
        </el-form-item>
        <el-form-item label="比对状态" prop="contrastStatus">
          <el-select
            v-model="queryParams.contrastStatus"
            placeholder="点击进行选择"
            clearable
            size="small"
            class="width170"
            @change="handleQuery"
          >
            <el-option label="已比对" value="1"/>
            <el-option label="未比对" value="0"/>
          </el-select>
        </el-form-item>
        <el-form-item label="证券业务" prop="isSecuritiesBusiness">
          <el-select
            v-model="queryParams.isSecuritiesBusiness"
            placeholder="点击进行选择"
            clearable
            size="small"
            class="width170"
            @change="handleQuery"
          >
            <el-option label="是" value="是"/>
            <el-option label="否" value="否"/>
          </el-select>
        </el-form-item>
     <el-form-item label="申请财政退回" prop="applyForFinancialRefund">
          <el-select
            v-model="queryParams.applyForFinancialRefund"
            placeholder="点击进行选择"
            clearable
            filterable
            size="small"
            class="width170"
            @change="handleQuery"
          >
            <el-option v-for="item in applyForFinancialRefundOption" v-if="item.value != 0" :label="item.label" :value="item.value"/>
          </el-select>
        </el-form-item>
        <!--   <el-form-item label="数据状态" prop="dataStatus">
          <el-select
            v-model="queryParams.dataStatus"
            placeholder="点击进行选择"
            clearable
            filterable
            size="small"
            class="width170"
            @change="handleQuery"
          >
            <el-option v-for="item in dataStatusOption" :label="item.label" :value="item.value"/>
          </el-select>
        </el-form-item>-->
        <el-form-item label="修改次数" prop="count">
          <el-input-number
            :min="0"
            controls-position="right"
            :precision="0"
            v-model="queryParams.count"
            placeholder="请输入修改次数"
            clearable
            size="small"
            class="width170"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
      </template>
      <el-form-item style="margin-left:60px;">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        <a @click="handleToggleSearch" style="margin-left: 8px">
          <span style="color: #1890FF; font-size:14px;">{{ toggleSearchStatus ? '收起' : '展开' }}</span>
          <i :class="toggleSearchStatus ? 'el-icon-arrow-up' : 'el-icon-arrow-down'" style="color: #1890FF;"></i>
        </a>
      </el-form-item>
    </el-form>
    <div class="marginBottom10">
      <el-button
        type="warning"
        icon="el-icon-download"
        size="mini"
        @click="applyPrintMore"
      >批量审核
      </el-button>
      <el-button
        type="warning"
        icon="el-icon-download"
        size="mini"
        @click="handleExport"
      >导出
      </el-button>
    </div>

    <el-table
      ref="myTable"
      :data="dataList"
      max-height="600"
      border
      stripe
      fit
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" fixed/>
      <!--      <el-table-column v-if="colData[21].isTrue" label="编号" prop="businessId"  :render-header="foo"/>-->
      <el-table-column v-if="computeFnColData('报告文号')" label="报告文号" prop="reportNo" :render-header="foo" width="120"/>
      <el-table-column v-if="computeFnColData('客户名称（被审验单位名称）')" label="客户名称（被审验单位名称）" prop="customerName" :render-header="foo"
                       width="120"/>
      <el-table-column v-if="computeFnColData('客户营业执照')" label="客户营业执照" width="130" prop="customerBusinessLicense"
                       :render-header="foo"/>
      <el-table-column v-if="computeFnColData('报备类型')" label="报备类型" prop="reportType" :render-header="foo" width="120"/>
      <el-table-column v-if="computeFnColData('审计年度')" label="审计年度" prop="auditYear" :render-header="foo" width="120"/>
      <el-table-column v-if="computeFnColData('报告日期')" label="报告日期" prop="reportTime" :render-header="foo" width="120"/>
      <el-table-column v-if="computeFnColData('申请财政退回的时间')" label="申请财政退回的时间" prop="applyTime" :render-header="foo" width="200"/>
      <el-table-column v-if="computeFnColData('财政退回审批的时间')" label="财政退回审批的时间" prop="applyVoidTime" :render-header="foo" width="200"/>
      <el-table-column v-if="computeFnColData('意见类型')" label="意见类型" prop="opinionType" :render-header="foo"
                       width="120"/>
      <el-table-column v-if="computeFnColData('签字注师1')" label="签字注师1" prop="assuranceBusinessDataRegisterSignatures"
                       :render-header="foo" width="120">
        <template slot-scope="scope">
          <span
            v-if="scope.row.assuranceBusinessDataRegisterSignatures && scope.row.assuranceBusinessDataRegisterSignatures[0] && scope.row.assuranceBusinessDataRegisterSignatures[0].registrantName">{{scope.row.assuranceBusinessDataRegisterSignatures[0].registrantName}}</span>
        </template>
      </el-table-column>
      <el-table-column v-if="computeFnColData('签字注师1编号')" label="签字注师1编号" prop="assuranceBusinessDataRegisterSignatures"
                       :render-header="foo" width="150">
        <template slot-scope="scope">
          <span
            v-if="scope.row.assuranceBusinessDataRegisterSignatures && scope.row.assuranceBusinessDataRegisterSignatures[0] && scope.row.assuranceBusinessDataRegisterSignatures[0].registrationCertificateNo">{{scope.row.assuranceBusinessDataRegisterSignatures[0].registrationCertificateNo}}</span>
        </template>
      </el-table-column>
      <el-table-column v-if="computeFnColData('签字注师2')" label="签字注师2" prop="assuranceBusinessDataRegisterSignatures"
                       :render-header="foo" width="120">
        <template slot-scope="scope">
          <span
            v-if="scope.row.assuranceBusinessDataRegisterSignatures && scope.row.assuranceBusinessDataRegisterSignatures[1] && scope.row.assuranceBusinessDataRegisterSignatures[1].registrantName">{{scope.row.assuranceBusinessDataRegisterSignatures[1].registrantName}}</span>
        </template>
      </el-table-column>
      <el-table-column v-if="computeFnColData('签字注师2编号')" label="签字注师2编号" prop="assuranceBusinessDataRegisterSignatures"
                       :render-header="foo" width="150">
        <template slot-scope="scope">
          <span
            v-if="scope.row.assuranceBusinessDataRegisterSignatures && scope.row.assuranceBusinessDataRegisterSignatures[1] && scope.row.assuranceBusinessDataRegisterSignatures[1].registrationCertificateNo">{{scope.row.assuranceBusinessDataRegisterSignatures[1].registrationCertificateNo}}</span>
        </template>
      </el-table-column>
      <el-table-column v-if="computeFnColData('收费金额')" label="收费金额" prop="chargeAmount" :render-header="foo"
                       width="120"/>
      <el-table-column v-if="computeFnColData('是否属于证券业务')" label="是否属于证券业务" prop="isSecuritiesBusiness"
                       :render-header="foo" width="120"/>
      <el-table-column v-if="computeFnColData('首次承接业务时间')" label="首次承接业务时间" prop="firstBusinessTime"
                       :render-header="foo" width="120"/>
      <el-table-column v-if="computeFnColData('防伪编码')" label="防伪编码" prop="antiCounterfeitingCoding" :render-header="foo"
                       width="120"/>
      <el-table-column v-if="computeFnColData('上报时间')" label="上报时间" prop="createTime" :render-header="foo" width="120"/>
      <el-table-column v-if="computeFnColData('财政系统报备编码')" label="财政系统报备编码" prop="reportCode" :render-header="foo"
                       width="150"/>
      <el-table-column v-if="computeFnColData('财政系统报备日期')" label="财政系统报备日期" prop="filingYear" :render-header="foo"
                       width="120"/>
      <el-table-column v-if="computeFnColData('备注')" label="备注" prop="officeRemarks" :render-header="foo" width="120"/>
      <el-table-column v-if="computeFnColData('修改次数')" label="修改次数" prop="count" sortable :render-header="foo"
                       width="120">
        <template slot-scope="scope">
          <span type="primary" plain size="mini">{{scope.row.count
            ?scope.row.count : '0'}}
          </span>
        </template>
      </el-table-column>
      <el-table-column v-if="computeFnColData('申请财政退回')" label="申请财政退回" prop="applyForFinancialRefund"
                       :render-header="foo" width="150">
        <template slot-scope="scope">
          <el-button type="primary" plain size="mini"  @click.native="handleOpenAppryReturnVisible(scope.row)" >
            {{formatApplyForFinancialRefund(scope.row.applyForFinancialRefund)}}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column v-if="computeFnColData('数据状态')" label="数据状态" prop="dataStatus" width="120">
        <template slot-scope="scope">
          <div>
            <span v-show="scope.row.dataStatus == 7">
              审核通过/正常/未比对
            </span>
            <span v-show="scope.row.dataStatus == 8">
                {{formatDataStatus(scope.row.dataStatus)}}
            </span>
            <span v-show="scope.row.dataStatus == 9" >
                 {{formatDataStatus(scope.row.dataStatus)}}
            </span>
            <span v-show="scope.row.dataStatus == 2"   v-hasPermi="['assurance:abnormal:relate']">
                 {{formatDataStatus(scope.row.dataStatus)}}
            </span>
            <span v-show="scope.row.dataStatus == 4">
               <el-button type="primary" plain size="mini"  @click.native="handleOpenVoidVisible(scope.row)">
                {{formatDataStatus(scope.row.dataStatus)}}
                </el-button>
            </span>
            <span v-show="scope.row.dataStatus == 2 && accountDisabled"
            >
                  {{formatDataStatus(scope.row.dataStatus)}}
            </span>
            <span v-show="scope.row.dataStatus == 3"
            >

                {{scope.row.contrastStatus == '0'?'正常/未比对': scope.row.contrastStatus == '2'?'正常/无需比对':'正常/已比对'}}

            </span>
            <span
              v-show="scope.row.dataStatus != 8 && scope.row.dataStatus != 9 && scope.row.dataStatus != 2 && scope.row.dataStatus != 3 && scope.row.dataStatus != 4 && scope.row.dataStatus != 7" >
              {{formatDataStatus(scope.row.dataStatus)}}
            </span>
          </div>

        </template>
      </el-table-column>
      <el-table-column v-judgeAccount="0" label="事务所名称" prop="firmName" :render-header="foo" width="120"/>
      <el-table-column v-judgeAccount="0" label="事务所证书号" prop="office" :render-header="foo" width="150">
        <template slot-scope="scope">
          {{scope.row.office.practiceCertificateNo}}
        </template>
      </el-table-column>

      <el-table-column v-judgeAccount="0" label="事务所行政区划" prop="administrativeDivision" :render-header="foo"
                       width="150">
        <template slot-scope="scope">
          {{scope.row.office.province}}
        </template>
      </el-table-column>
      <el-table-column v-judgeAccount="0" label="财政系统报备状态" prop="reportStatus" sortable :render-header="foo"
                       width="150"/>
      <el-table-column v-judgeAccount="0" label="是否有证券资格" prop="hasSecurities" :render-header="foo" width="150"/>
      <!--<el-table-column v-if="computeFnColData('操作')" label="操作" align="center" width="150" fixed="right">
        <template slot-scope="scope">
         &lt;!&ndash; <el-button type="primary" plain size="mini" @click="handleDetail(scope.row)"
                     v-hasPermi="['assurance:data:view']">查看
          </el-button>&ndash;&gt;
          <el-button type="primary" plain size="mini" v-if="scope.row.applyForFinancialRefund == 1 || scope.row.applyForFinancialRefund == -2"
                     @click="handleExamine(scope.row,'同意',2)">同意退回
          </el-button>
          <el-button type="primary" plain size="mini" v-if="scope.row.applyForFinancialRefund == 1 scope.row.applyForFinancialRefund == -2"
                     @click="handleExamine(scope.row,'拒绝',-2)">拒绝退回
          </el-button>
        </template>
      </el-table-column>-->
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      :autoScroll="false"
      @pagination="getList"
    >
      <template v-slot:popover>
        <el-popover
          placement="top-end"
          width="260"
          trigger="hover"
        >
          <!--弹出的菜单内容-->
          <div class="selectMenu">
            <el-checkbox-group v-model="colOptions">
              <el-checkbox v-for="item in colSelect" :key="item" :label="item" class="displayBlock marginBottom10"/>
            </el-checkbox-group>
          </div>
          <el-button slot="reference" size="mini" class="selectBtn">
            <i class="el-icon-menu"></i><i class="el-icon-caret-bottom"></i>
          </el-button>
        </el-popover>
      </template>
    </pagination>
    <el-dialog
      title="审核申请退回数据"
      :visible.sync="strongExamineDataVisible"
      width="360px"
      append-to-body
      center
    >
      <el-form :model="commonForm" :rules="commonFormRules" ref="commonForm">
        <el-form-item prop="reason">
          <el-input v-model="commonForm.reason" type="textarea" :rows="8" placeholder="请输入理由..."></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleExamine(2)">同意退回</el-button>
        <el-button type="danger" @click="handleExamine(-2)">拒绝退回</el-button>
        <el-button @click="strongExamineDataVisible=false;">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import AuditReport from '@/views/components/audit-report';
  import AuditReportQrcode from '@/views/components/audit-report-qrcode';
  import AuditReportMore from '@/views/components/audit-report-more';
  import {getToken} from "@/utils/auth";
  import {
    listAssurance,
    voidBusinessData,
    getAssurancePass,
    examineBusinessDataPass,
    strongExamineBusinessDataPass,
    getEditHistoryByBusinessId,
    getFailedReason,
    exportBusinessRefundData,
    getImportByTaskNo,
    getVoidReason,
    getApplyReturnReason,
    getApplyReturnNoReason,
    importEditHistory
  } from "@/api/system/assurance";

  export default {
    name: "AssuranceList",
    components: {AuditReport, AuditReportQrcode, AuditReportMore},
    data() {
      return {
        aaa: '',
        auditReportVisibleQrCode: false,
        auditReportVisibleMore: false,
        toggleSearchStatus: false,
        historyBusinessId: '',
        fBusinessId: '',
        qrfBusinessId: '',
        fBusinessData: '',
        selectNum: 0, // 已选择项 条数
        activeStep: 1,  // 当前完成几步
        taskNo: '',  // 上注协导入 编号
        taskNoResult: {
          currentStage: '',
          finishMessage: '',
          taskNo: '',
          taskStatus: '', // 0执行中，1正常结束，2任务异常结束
          stageDetail: [],
          failMessageList: [],
        },
        scipaResultVisible: false, // 上注协导入结果 弹框
        auditReportVisible: false, // 审计报告 弹框
        dataVisible: false, // 业务数据修改弹框
        voidVisible: false, // 作废业务数据弹框
        approvalVisible: false, // 财政审批弹框
        examineDataVisible: false, // 待审核事务所数据
        strongExamineDataVisible: false, // 强审核异常数据
        progressVisible: false, // 导入中
        resultVisible: false, // 导入 结果
        failedVisible: false, // 导入 失败
        loading: false,
        ids: [], // 选中数组
        single: true, // 非单个禁用
        multiple: true, // 非多个禁用
        total: 0, // 总条数
        commonForm: {},// 审批表单
        commonFormRules: {
          reason: [
            {required: true, trigger: "blur", message: "理由不能为空"},
          ],
        },
        // 申请财政退回状态
        applyForFinancialRefundOption: [
          {label: '未申请', value: '0'},
          {label: '已申请', value: '1'},
          {label: '通过', value: '2'},
          {label: '不通过', value: '-2'}
        ],
        // 数据状态
        dataStatusOption: [
          {label: '不予报备', value: '0'},
          {label: '强审通过', value: '1'},
          {label: '数据异常', value: '2'},
          {label: '正常', value: '3'},
          {label: '作废', value: '4'},
          {label: '预上传', value: '5'},
          {label: '待审核', value: '6'},
          {label: '审核通过', value: '7'},
          {label: '审核不通过', value: '8'},
          {label: '待确认', value: '9'},
        ],
        reportTypeOption: [], // 报备类型
        opinionTypeOption: [], // 意见类型
        picturePrefix: 'data:image/png;base64,', // 图片前缀
        opinions: [],
        // 查询 表单
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          customerName: '', // 客户名称（被审验单位名称）
          customerBusinessLicense: '', // 客户营业执照号
          auditYear: '', // 审计年度
          reportType: '', // 报备类型
          filingYear: '', // 报备年度
          filingTime: '', // 报备日期
          reportTime: '', // 报告日期
          reportNo: '', // 报备文号
          reportCode: '', // 报备编码
          reportStatus: '', // 报备状态
          opinionType: '', // 意见类型
          administrativeDivision: '', // 事务所行政划分
          firmName: '', // 事务所名称 100
          hasSecurities: '', // 证券资格 100
          isSecuritiesBusiness: '', // 证券业务 100
          signCertificateNo1: '', // 签字注册师证号
          signerName1: '',//签字注册师
          antiCounterfeitingCoding: '',// 防伪编码
          contrastStatus: '', // 比对状态
          applyForFinancialRefund:1
        },
        // 审计年度 year日期选择器  开始年度和结束年度 添加限制
        pickerStartAuditYear: {
          disabledDate: time => {
            if (this.queryParams.auditYearEndTime) {
              return time.getTime() > this.queryParams.auditYearEndTime
            }
          }
        },
        pickerEndAuditYear: {
          disabledDate: time => {
            return time.getTime() < this.queryParams.auditYearStartTime
          }
        },
        // 报备年度 year日期选择器  开始年度和结束年度 添加限制
        pickerStartFilingYear: {
          disabledDate: time => {
            if (this.queryParams.filingYearEndTime) {
              return time.getTime() > this.queryParams.filingYearEndTime
            }
          }
        },
        pickerEndFilingYear: {
          disabledDate: time => {
            return time.getTime() < this.queryParams.filingYearStartTime
          }
        },
        reportTime: undefined,
        filingTime: undefined,
        applyVoidTime:undefined,
        // 表格 列表数据
        dataList: [],
        // 修改历史 表格
        editDataList: [],
        defaultProps: {
          children: 'children',
          label: 'label'
        },
        fileList: [], // 上传 文件列表（唯一）
        resultData: {}, // 上传后 数据结果
        // 业务数据 导入参数
        upload: {
          open: false,
          // 弹出层标题（业务导入）
          title: "业务导入",
          // 是否禁用上传
          isUploading: false,
          // 是否更新已经存在的用户数据
          updateSupport: 0,
          // 设置上传的请求头部
          headers: {Authorization: "Bearer " + getToken()},
          // 上传的地址
          url: process.env.VUE_APP_BASE_API + "/system/user/importData",
        },
        // 表格 自定义展示列
        colOptions: ['事务所名称', '报备状态', '事务所行政区划', '是否有证券资格', '客户名称（被审验单位名称）', '客户营业执照', '报备类型', '审计年度', '报备年度', '报告文号', '报备编码', '收费金额', '是否属于证券业务', '首次承接业务时间', '意见类型', '报告日期', '报备日期', '修改次数', '操作', '申请财政退回', '数据状态', '比对状态', '签字注师1', '签字注师1编号', '签字注师2', '签字注师2编号', '上报时间', '备注', '事务所证书号'],  //多选框的选择项
        colSelect: ['客户名称（被审验单位名称）', '客户营业执照', '报备类型', '审计年度', '报备年度', '报告文号', '报备编码', '收费金额', '是否属于证券业务', '首次承接业务时间', '意见类型', '报告日期', '报备日期', '修改次数', '操作', '申请财政退回', '数据状态', '比对状态'],	//多选框已选择的内容，即表格中显示的列
        // isTrue属性存放列的状态
        colData: [
          {title: '客户名称（被审验单位名称）', isTrue: true},
          {title: '客户营业执照', isTrue: true},
          {title: '报备类型', isTrue: true},
          {title: '审计年度', isTrue: true},
          {title: '报备年度', isTrue: false},
          {title: '报告文号', isTrue: true},
          {title: '申请财政退回的时间', isTrue: true},
          {title: '财政退回审批的时间', isTrue: true},
          {title: '报备编码', isTrue: false},
          {title: '收费金额', isTrue: true},
          {title: '是否属于证券业务', isTrue: false},
          {title: '首次承接业务时间', isTrue: false},
          {title: '意见类型', isTrue: true},
          {title: '报告日期', isTrue: false},
          {title: '报备日期', isTrue: false},
          {title: '修改次数', isTrue: true},
          {title: '操作', isTrue: true},
          {title: '申请财政退回', isTrue: true},
          {title: '数据状态', isTrue: true},
          {title: '防伪编码', isTrue: true},
          {title: '比对状态', isTrue: true},
          {title: '签字注师1', isTrue: true},
          {title: '签字注师1编号', isTrue: true},
          {title: '签字注师2', isTrue: true},
          {title: '签字注师2编号', isTrue: true},
          {title: '上报时间', isTrue: true},
          {title: '备注', isTrue: true},
        ],
      };
    },
    beforeUpdate() {
      // 防止动态添加列时 表格乱
      this.$nextTick(() => {
        this.$refs.myTable.doLayout();
      });
    },
    watch: {
      colOptions(newVal, oldVal) {
        if (newVal) {    // 如果有值发生变化，即多选框的已选项变化
          let arr = this.colSelect.filter(i => newVal.indexOf(i) < 0) 	// 未选中
          this.colData.filter(i => {
            if (arr.indexOf(i.title) !== -1) {
              i.isTrue = false
            } else {
              i.isTrue = true
            }
          })
        }
      },
    },
    created() {
      this.colOptions = [];
      this.colData.forEach(item => {
        if (item.isTrue) {
          this.colOptions.push(item.title);
        }
      });
      this.getDicts("report_type").then(response => {
        // 报备类型
        this.reportTypeOption = response.data;
      });
      this.getDicts("type_of_opinion").then(response => {
        // 意见类型
        this.opinions = response.data;
      });
        this.getList();
    },
    methods: {
      computeFnColData(str) {
        let boolres = false
        this.colData.forEach((item) => {
          if (item.title == str) {
            boolres = item.isTrue
          }
        })
        return boolres
      },
      handleToggleSearch() {
        this.toggleSearchStatus = !this.toggleSearchStatus;
      },
      /** 导出按钮操作 */
      handleExport() {
        let queryParams = this.queryParams;
        queryParams.ids = this.ids.join(",");
        this.ids=[]
        this.$confirm('是否确认导出所有业务数据?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function () {
          return exportBusinessRefundData(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function () {
        });
      },
      // 批量审核
      applyPrintMore() {
        if (this.ids.length < 1) {
          this.$message({
            message: '请选择有效数据!',
            type: 'error'
          });
          return
        }
        let num = 0
        let list = [];
        this.dataList.forEach((item) => {
          if (this.ids.includes(item.businessId)) {
            if(item.applyForFinancialRefund == '1' || item.applyForFinancialRefund == '-2'){
              list.push(item.businessId)
            }else{
              num++
            }
          }
        })
        if(num<=0) {
          this.strongExamineDataVisible = true
          this.commonForm = {"reason": "已审核"};
          this.commonForm.ids = this.ids;
          if (this.$refs.commonForm) {
            this.$refs.commonForm.clearValidate(['reason']); // 清空单一校验
          } // 清空单一校验
        }else{
          this.$message({
            message: '有'+num+'条数据不符合审核要求!',
            type: 'info'
          });
        }
        this.uploadloading = true;
      },
      handleExamine( num) {

        // applyForFinancialRefund: 2：财政退回通过，-2：财政退回不通过
        let params = {
          applyForFinancialRefund: num,
          ids: this.commonForm.ids.join(","),
          reason: this.commonForm.reason
        }
        getAssurancePass(params).then(
          response => {
            this.$message({
              type: 'success',
              message: `审核成功`
            });
            this.getList()
            this.strongExamineDataVisible = false;
          }
        ).catch(() => {
          this.$message({
            type: 'info',
            message: `取消操作`
          });
          this.strongExamineDataVisible = false;
        })

      },
      /** 强审 提交 */
      handleSubmitStrongExamine(status) {
        let params = {
          businessId: this.commonForm.businessId,
          dataStatus: status,
          strongReason: this.commonForm.reason
        }
        this.$refs.commonForm.validate(valid => {
          if (valid) {
            this.$confirm('是否确认强审通过该条数据?', "警告", {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
            }).then(response => {
              strongExamineBusinessDataPass(params).then(res => {
                this.strongExamineDataVisible = false;
                this.getList();
                this.$message({
                  message: '操作成功!',
                  type: 'success'
                });
              });
              this.ids = []
            }).catch(function () {
            });
          }
        })
      },
      selectBlur(e) {
        // 意见类型
        if (e.target.value !== '') {
          this.queryParams.opinionType = e.target.value + '(其他)';
          this.$forceUpdate()
          this.handleQuery()
        }
      },
      selectClear() {
        this.queryParams.opinionType = ''
        this.$forceUpdate()
        this.handleQuery()
      },
      selectChange(val) {
        this.queryParams.opinionType = val
        this.$forceUpdate()
        this.handleQuery()
      },

      foo(h, {column}) {
        return this.utilsFoo(h, {column})
      },
      handleOpenVoidVisible(row){
        getVoidReason(row.businessId).then(res => {
          this.$confirm(res.msg, '作废原因', {
            showConfirmButton: false,
            cancelButtonText: '关闭',
            type: 'warning'
          }).then(() => {
          }).catch(() => {
          });
        });
      },
      handleOpenAppryReturnVisible(row){
        if(row.applyForFinancialRefund ==='1'){
          getApplyReturnReason(row.businessId).then(res => {
            this.$confirm(res.msg, '申请财政退回原因', {
              showConfirmButton: false,
              cancelButtonText: '关闭',
              type: 'warning'
            }).then(() => {
            }).catch(() => {
            });
          });
        }
        if(row.applyForFinancialRefund ==='0'){
          this.$confirm("未申请", '申请财政退回', {
            showConfirmButton: false,
            cancelButtonText: '关闭',
            type: 'warning'
          }).then(() => {
          }).catch(() => {
          });
        }
        if(row.applyForFinancialRefund ==='2'){
          this.$confirm("已通过", '申请财政退回', {
            showConfirmButton: false,
            cancelButtonText: '关闭',
            type: 'warning'
          }).then(() => {
          }).catch(() => {
          });
        }
        if(row.applyForFinancialRefund ==='-2'){
          getApplyReturnNoReason(row.businessId).then(res => {
            this.$confirm(res.msg, '申请财政退回不通过原因', {
              showConfirmButton: false,
              cancelButtonText: '关闭',
              type: 'warning'
            }).then(() => {
            }).catch(() => {
            });
          });
        }

      },
      formatDataStatus(dataStatus) {
        // 数据状态：0：不予报备，1：强审通过，2：数据异常，3：正常，4：作废，5：预上传，6：待审核，7：审核通过，8：审核不通过
        switch (dataStatus) {
          case '0':
            return '不予报备';
          case '1':
            return '强审通过';
          case '2':
            return '数据异常';
          case '3':
            return '正常';
          case '4':
            return '作废';
          case '5':
            return '预上传';
          case '6':
            return '待审核';
          case '7':
            return '审核通过';
          case '8':
            return '审核不通过';
          case '9':
            return '待确认';
        }
      },
      formatApplyForFinancialRefund(applyForFinancialRefund) {
        switch (applyForFinancialRefund) {
          case '0':
            return '未申请';
          case '1':
            return '已申请';
          case '2':
            return '通过';
          case '-2':
            return '不通过';
        }
      },
      /** 查询鉴证业务列表 */
      getList() {
        //报告日期
        this.queryParams.reportTimeStartTime = this.reportTime && this.reportTime[0] ? this.reportTime[0] : '';
        this.queryParams.reportTimeEndTime = this.reportTime && this.reportTime[1] ? this.reportTime[1] : '';
        //报备日期
        this.queryParams.filingTimeStartTime = this.filingTime && this.filingTime[0] ? this.filingTime[0] : '';
        this.queryParams.filingTimeEndTime = this.filingTime && this.filingTime[1] ? this.filingTime[1] : '';
        this.queryParams.filingTimeStartTime = this.filingTime && this.filingTime[0] ? this.filingTime[0] : '';
        this.queryParams.filingTimeEndTime = this.filingTime && this.filingTime[1] ? this.filingTime[1] : '';
        this.queryParams.applyVoidTimeStartTime = this.applyVoidTime && this.applyVoidTime[0] ? this.applyVoidTime[0] : '';
        this.queryParams.applyVoidTimeEndTime = this.applyVoidTime && this.applyVoidTime[1] ? this.applyVoidTime[1] : '';
        this.loading = true;
        let params = JSON.stringify(this.queryParams)
        let initParams = JSON.parse(params)
        if (initParams.reportNo && initParams.reportNo != "") {
          initParams.reportNo = encodeURI(initParams.reportNo);
        }
        listAssurance(initParams).then(
          response => {
            this.dataList = response.rows;
            this.total = response.total;
            this.loading = false;
          }
        );
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.ids=[];
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.reportTime = [];
        this.filingTime = [];
        this.applyVoidTime=[];
        this.ids=[];
        this.queryParams.filingYearStartTime = '';
        this.queryParams.filingYearEndTime = '';
        this.queryParams.auditYearStartTime = '';
        this.queryParams.auditYearEndTime = '';
        this.queryParams.applyVoidTimeStartTime = '';
        this.queryParams.applyVoidTimeEndTime = '';
        this.resetForm("queryForm");
        this.handleQuery();
      },
      /** 多选框选中数据 */
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.businessId)
        this.single = selection.length != 1
        this.multiple = !selection.length;

      },
      /** 查看详情按钮操作 */
      handleDetail(row) {
        this.$router.push({path: '/assurance/detail', query: {businessId: row.businessId}})
      }
    }

  };
</script>
<style lang="scss" scoped>
  .app-container {
    position: relative;
  }

  /*form 表单 样式设置 start*/
  ::v-deep .el-form-item {
    margin-bottom: 10px;
  }

  ::v-deep label[for='unifiedSocialCreditCode'],
  ::v-deep label[for='nameOfChargePerson'],
  ::v-deep label[for='certificateNoOfResponsity'] {
    line-height: 20px;
  }

  ::v-deep .el-input--suffix .el-input__inner {
    padding-right: 10px;
  }

  ::v-deep .el-select .el-input--suffix .el-input__inner {
    padding-right: 30px;
  }

  ::v-deep .el-date-editor .el-range-input {
    width: 62%;
  }

  /*form 表单 样式设置 end*/

  .width74 {
    width: 74px;
  }

  .width170 {
    width: 170px;
  }

  .failedContent {
    margin-top: 20px;
    padding: 10px;
    border: 1px dashed #ccc;

    p {
      line-height: 24px;
    }
  }

  /*步骤条*/
  .stepView {
    margin: 0 auto 30px auto;
    width: fit-content;
    height: 360px;
    text-align: center;
    position: relative;

    ::v-deep .el-step__title.is-finish,
    ::v-deep .el-step__title.is-process,
    ::v-deep .el-step__title.is-wait {
      color: #555;
      font-weight: 400;
    }

    ::v-deep .el-step.is-vertical {
      .el-step__line {
        border-color: transparent;
        top: 1px;
        left: 10px;
        border-style: dashed;
        background: transparent;

        &:after {
          content: '•••';
          position: absolute;
          top: 15px;
          left: -4px;
          color: #C0C4CC;
          //transform: translate(-50%, -50%) rotate(90deg);
          font-size: 14px;
          letter-spacing: 0;
        }
      }
    }

    ::v-deep .el-step__head.is-finish {
      color: #fff;

      .el-step__icon.is-text {
        background: #4667db;
        border-width: 1px;
      }

      .el-step__line {
        &:after {
          color: #4667db;
        }
      }
    }

    ::v-deep .el-step__head.is-process {
      color: #555;

      .el-step__icon.is-text {
        background: #fff;
        border-color: #C0C4CC;
        border-width: 1px;
      }

      .el-step__line {
        &:after {
          color: #C0C4CC;
        }
      }
    }

    ::v-deep .el-step__head.is-wait {
      color: #555;

      .el-step__icon.is-text {
        background: #fff;
        border-width: 1px;
      }
    }

    ::v-deep .el-step__icon-inner {
      font-weight: 400;
    }
  }

  .printMeWrap {
    ::v-deep .el-dialog .el-dialog__body {
      flex: none !important;
    }
  }

  ::v-deep .el-dialog .el-dialog__body {
    min-height: 240px;
  }

  .printMeWrap.qr {
    ::v-deep .el-dialog .el-dialog__body {
      height: 400px;
    }
  }

  @page {
    size: auto A4 landscape;
    margin: 3mm;
  }
</style>
